<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Advancedsearch extends MY_Controller {

	/**
	 * Index Page for this controller.
	 *
	 * Maps to the following URL
	 * 		http://example.com/index.php/welcome
	 *	- or -  
	 * 		http://example.com/index.php/welcome/index
	 *	- or -
	 * Since this controller is set as the default controller in 
	 * config/routes.php, it's displayed at http://example.com/
	 *
	 * So any other public methods not prefixed with an underscore will
	 * map to /index.php/welcome/<method_name>
	 * @see http://codeigniter.com/user_guide/general/urls.html
	 */
	public function index()
	{
		
		}
	function search(){
	
		$vewArray = '';
	
		$this->page("search",$vewArray);
	
	
	}
	
	function search_result(){
		
		$this->load->library('pagination');
		
		$searchArr = '';
		$searchArr["details"] = '';
		$this->model_member->search();
		$count = $this->model_member->num_rows;
		$searchArr['total_count'] = $count;
		
		#PAGIN MAHESH.
		$config['base_url'] =site_url('/advancedsearch/search_result/?');
		$config['total_rows'] = $count;
		$config['per_page'] =15;
		$config['num_links'] = 1;
	
		$config['page_query_string'] = TRUE;
		$config['cur_tag_open'] = '<span>';
		$config['cur_tag_close'] = '</span>';
		$config['use_page_numbers'] = TRUE;
		$this->pagination->initialize($config);
		$searchArr["pagination_link"] = $this->pagination->create_links();

		# PAGINATION
/*		$config = array();
        $config["base_url"] = base_url() . "/index.php/advancedsearch/search_result";
        $config["total_rows"] =$count;
        $config["per_page"] = 1;
        $config["uri_segment"] = 3;
		$this->pagination->initialize($config);
		$searchArr['pagination_link'] = $this->pagination->create_links();*/
		
		$page = ($this->input->get('per_page')) ? $this->input->get('per_page') : 1;
		$frompg = ($page * $config["per_page"]) - $config["per_page"];
		$this->model_member->searchAll($config["per_page"],$frompg);
		if($this->model_member->num_rows){
				$vewArray = '';
				$pforle	  = '';
				foreach ($this->model_member->query->result() as $row){
				$member_id         			= $row->id;
				$vewArray["member_id"]      = $member_id;
				$vewArray["unique_id"] 		= $row->unique_id;
				$vewArray["fname"] 			= $row->fname;
				$vewArray["lname"] 			= $row->lname;
			 	$vewArray["profile_picture"]= $this->model_photos->getMemberProfilePicture($member_id);
				$pforle						= $this->model_photos->getMemberProfilePicture($member_id);
				$vewArray["age"]			= floor((time() - ($row->dob)) / 31556926);
				$vewArray["height"]			= $row->height;
				# Ocupation
				$vewArray["occupation"]     = $row->occupation;
				# Education 
				$vewArray["education"]      = $row->education;
				
				if(file_exists("http://localhost/new/CI/m/my-google-testproject/trunk//uploads/$pforle"));
				$searchArr["details"].= $this->load->view('infinite_inner',$vewArray,TRUE);
				//infinite_inner
				}
		
		}
	
		$this->page("infinite_scroll",$searchArr);
	
	
	}	
}